package com.ruoyi.web.controller.gcgl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.config.ServerConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.gcgl.domain.GcCustomer;
import com.ruoyi.gcgl.domain.GcProject;
import com.ruoyi.gcgl.domain.GcProjectFlow;
import com.ruoyi.gcgl.domain.GcProjectQtfy;
import com.ruoyi.gcgl.mapper.GcSendTipMapper;
import com.ruoyi.gcgl.service.IGcCustomerService;
import com.ruoyi.gcgl.service.IGcProjectFlowService;
import com.ruoyi.gcgl.service.IGcProjectQtfyService;
import com.ruoyi.gcgl.service.IGcProjectService;
import com.ruoyi.gcgl.service.IGcSendTipService;
import com.ruoyi.web.controller.tool.AliyunSmsUtils;

/**
 * 项目其它费用Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@Controller
@RequestMapping("/gcgl/qtfy")
public class GcProjectQtfyController extends BaseController{
	
	private static final Logger log = LoggerFactory.getLogger(GcProjectQtfyController.class);
	
    private String prefix = "gcgl/qtfy";

    @Autowired
    private IGcProjectQtfyService gcProjectQtfyService;
    @Autowired
    private IGcProjectService gcProjectService;
    @Autowired
    private IGcProjectFlowService gcProjectFlowService;
    @Autowired
    private ServerConfig serverConfig;
    
    private static final String FILE_DELIMETER = ",";
    @Autowired
    private IGcCustomerService gcCustomerService;
    @Autowired
    private IGcSendTipService gcSendTipService;
    @Autowired
    private GcSendTipMapper gcSendTipMapper;

    @RequiresPermissions("gcgl:qtfy:view")
    @GetMapping()
    public String qtfy()
    {
        return prefix + "/qtfy";
    }

    /**
     * 查询项目其它费用列表
     */
    @RequiresPermissions("gcgl:qtfy:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(GcProjectQtfy gcProjectQtfy)
    {
        startPage();
        gcProjectQtfy.setDeleteFlag(1);
        if(getSysUser().isShow43R(getUserId())){
        	gcProjectQtfy.setCreateUser(getLoginName());
        }
        List<GcProjectQtfy> list = gcProjectQtfyService.selectGcProjectYbfyList(gcProjectQtfy);
        for(GcProjectQtfy obj:list){
        	if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
        	obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
        	}
        	
        	GcProject gcProject = gcProjectService.selectGcProjectById(obj.getGcProjectid());
        	obj.setStatus(gcProject.getStatus());
        }
        return getDataTable(list);
    }

    /**
     * 导出项目其它费用列表
     */
    @RequiresPermissions("gcgl:qtfy:export")
    @Log(title = "项目其它费用", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(GcProjectQtfy gcProjectQtfy)
    {
    	gcProjectQtfy.setDeleteFlag(1);
        if(getSysUser().isShow()){
        	gcProjectQtfy.setCreateUser(getLoginName());
        }
        List<GcProjectQtfy> list = gcProjectQtfyService.selectGcProjectYbfyList(gcProjectQtfy);
        ExcelUtil<GcProjectQtfy> util = new ExcelUtil<GcProjectQtfy>(GcProjectQtfy.class);
        return util.exportExcel(list, "项目其它费用数据");
    }

    /**
     * 新增项目其它费用
     */
    @GetMapping("/add/{gcProjectid}")
    public String add(ModelMap mmap,@PathVariable("gcProjectid") Long gcProjectid){
    	GcProject gcProject = gcProjectService.selectGcProjectById(gcProjectid);
    	mmap.put("gcProject", gcProject);
    	
    	GcCustomer gcCustomer = new GcCustomer();
    	gcCustomer.setDeleteFlag(1);
    	List<GcCustomer> gcCustomerlis = gcCustomerService.selectGcCustomerList(gcCustomer);
    	mmap.put("clis", gcCustomerlis);
        return prefix + "/add";
    }

    /**
     * 新增保存项目其它费用
     */
    @RequiresPermissions("gcgl:qtfy:add")
    @Log(title = "项目其它费用", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public synchronized AjaxResult addSave(GcProjectQtfy gcProjectQtfy){
    	
    	try{
//            SimpleDateFormat sdy = new SimpleDateFormat("yyyy");
//    		SimpleDateFormat sdm = new SimpleDateFormat("MM");
//    		int year = Integer.parseInt(sdy.format(new Date()));
//    		int month = Integer.parseInt(sdm.format(new Date()));
//    		GcProjectQtfy newObj = new GcProjectQtfy();
//    		newObj.setDeleteFlag(1);
//    		newObj.setCreateAt(DateUtils.getFisrtDayOfMonth(year, month));
//    		newObj.setUpdateAt(DateUtils.getLastDayOfMonth(year, month));
//    		List<GcProjectQtfy> lisCount = gcProjectQtfyService.selectGcProjectYbfyList(newObj);
//    		String no = String.format("%02d", lisCount.size()+1);
//    		gcProjectQtfy.setOrderNo(year+"-"+no);
    		
    		GcProject gcProject = gcProjectService.selectGcProjectById(gcProjectQtfy.getGcProjectid());
    		gcProjectQtfy.setOrderNo(gcProject.getOrderNo());
    		
    		GcCustomer customer = gcCustomerService.selectGcCustomerById(gcProjectQtfy.getSupplyId());
    		gcProjectQtfy.setSupplyName(customer.getName());
    		
            gcProjectQtfy.setDeleteFlag(1);
            gcProjectQtfy.setCreateAt(new Date());
            gcProjectQtfy.setUpdateAt(new Date());
            gcProjectQtfy.setCreateUser(getLoginName());
            gcProjectQtfy.setUpdateUser(getLoginName());
            gcProjectQtfy.setStatus(3);
            gcProjectQtfyService.insertGcProjectYbfy(gcProjectQtfy);
            
            //查询流程图
            GcProjectFlow gcProjectFlow = new GcProjectFlow();
            gcProjectFlow.setGcProjectid(gcProjectQtfy.getGcProjectid());
            gcProjectFlow = gcProjectFlowService.selectGcProjectFlowList(gcProjectFlow).get(0);
            
            GcProjectFlow obj = new GcProjectFlow();
            //判断是否启用项目审批节点
            if(gcProjectFlow.getSjtz()==1 && gcProjectFlow.getQtwj()==1 
            		&& gcProjectFlow.getZjbj()==1 && gcProjectFlow.getCbyg()==1  && gcProjectFlow.getHtxq()==1){
            	obj.setXmps(1);
            }
            obj.setXmqtfy(1);
            obj.setGcProjectid(gcProjectFlow.getGcProjectid());
            gcProjectFlowService.updateGcProjectFlow(obj);
            
            //发送消息通知
//        	gcSendTipService.sendTip("bzj", gcProjectQtfy.getName(), gcProjectQtfy.getOrderNo(), 
//        			gcProjectQtfy.getCreateUser(), DateUtils.dateTime(gcProjectQtfy.getCreateAt()), 
//        			gcProjectQtfy.getStatus().toString(), null, gcProjectQtfy.getId().toString());
            
            try {
        		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(gcProjectQtfy.getCreateUser());
        		if(userlis!=null && userlis.size()>0){
        			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
        			AliyunSmsUtils.returnSmsTz(phonenumber);
        		}
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
        }
        catch (Exception e){
            log.error("上传文件！", e);
            return error(e.getMessage());
        }
    	
        return toAjax(1);
    }

    /**
     * 修改项目其它费用
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        GcProjectQtfy gcProjectQtfy = gcProjectQtfyService.selectGcProjectYbfyById(id);
        if(gcProjectQtfy.getZlwj()!=null && !gcProjectQtfy.getZlwj().equals("")){
        	String[] zlis = gcProjectQtfy.getZlwj().split(",");
        	String file = "";
        	for(int i=0;i<zlis.length;i++){
        		file += RuoYiConfig.getOnPath()+zlis[i]+",";
        	}
        	gcProjectQtfy.setZlwj(file);
        }
        mmap.put("gcProjectQtfy", gcProjectQtfy);
        
        GcCustomer gcCustomer = new GcCustomer();
    	gcCustomer.setDeleteFlag(1);
    	List<GcCustomer> gcCustomerlis = gcCustomerService.selectGcCustomerList(gcCustomer);
    	mmap.put("clis", gcCustomerlis);
        return prefix + "/edit";
    }

    /**
     * 修改保存项目其它费用
     */
    @Log(title = "项目其它费用", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(GcProjectQtfy gcProjectQtfy)
    {
    	try{
    		GcCustomer customer = gcCustomerService.selectGcCustomerById(gcProjectQtfy.getSupplyId());
    		gcProjectQtfy.setSupplyName(customer.getName());
    		
            gcProjectQtfy.setStatus(0);
            gcProjectQtfy.setUpdateAt(new Date());
            gcProjectQtfy.setUpdateUser(getLoginName());
            gcProjectQtfy.setSpr("");
            gcProjectQtfy.setZjl("");
            gcProjectQtfyService.updateGcProjectYbfy(gcProjectQtfy);
        }
        catch (Exception e){
            log.error("上传文件！", e);
            return error(e.getMessage());
        }
    	
        return toAjax(1);
    }

    /**
     * 删除项目其它费用
     */
    @RequiresPermissions("gcgl:qtfy:remove")
    @Log(title = "项目其它费用", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(gcProjectQtfyService.deleteGcProjectYbfyByIds(ids));
    }
    
    //项目评审
    @RequiresPermissions("gcgl:qtfy:psview")
    @GetMapping("/ps")
    public String ybfyps(){
        return prefix + "/qtfyps";
    }
    
    /**
     * 查询项目其它费用列表
     */
    @PostMapping("/pslist")
    @ResponseBody
    public TableDataInfo pslist(GcProjectQtfy gcProjectQtfy)
    {
        startPage();
        gcProjectQtfy.setDeleteFlag(1);
        gcProjectQtfy.setStatus(0);
        List<GcProjectQtfy> list = gcProjectQtfyService.selectGcProjectYbfyList(gcProjectQtfy);
        for(GcProjectQtfy obj:list){
        	if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
        	obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
        	}
        }
        return getDataTable(list);
    }
    
    @Log(title = "通过", businessType = BusinessType.UPDATE)
    @PostMapping("/yes")
    @ResponseBody
    public AjaxResult yes(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcProjectQtfy qtfy = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i].toString()));
    		if(qtfy!=null){
    			GcProjectQtfy gcProjectQtfy = new GcProjectQtfy();
        		gcProjectQtfy.setId(Long.parseLong(id[i]));
        		gcProjectQtfy.setStatus(1);
        		gcProjectQtfy.setSpr(getLoginName());
        		gcProjectQtfy.setSprAt(new Date());
        		gcProjectQtfy.setSpyj(spyj);
        		gcProjectQtfyService.updateGcProjectYbfy(gcProjectQtfy);
        		
        		GcProjectQtfy obj = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i]));
        		//发送消息通知
//            	gcSendTipService.sendTip("bzj", obj.getName(), obj.getOrderNo(), 
//            			obj.getCreateUser(), DateUtils.dateTime(obj.getCreateAt()), 
//            			obj.getStatus().toString(), null, obj.getId().toString());
        		
        		try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    		
    	}
    	
    	return toAjax(1);
    }
    
    @Log(title = "不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/no")
    @ResponseBody
    public AjaxResult no(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcProjectQtfy qtfy = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i].toString()));
    		if(qtfy!=null){
    			GcProjectQtfy gcProjectQtfy = new GcProjectQtfy();
        		gcProjectQtfy.setId(Long.parseLong(id[i]));
        		gcProjectQtfy.setStatus(2);
        		gcProjectQtfy.setSpr(getLoginName());
        		gcProjectQtfy.setSprAt(new Date());
        		gcProjectQtfy.setSpyj(spyj);
            	gcProjectQtfyService.updateGcProjectYbfy(gcProjectQtfy);
            	
            	GcProjectFlow gcProjectFlow = new GcProjectFlow();
            	gcProjectFlow.setGcProjectid(qtfy.getGcProjectid());
            	gcProjectFlow.setXmqtfy(0);
            	gcProjectFlow.setUpdateAt(new Date());
            	gcProjectFlow.setUpdateUser(getLoginName());
            	gcProjectFlowService.updateGcProjectFlow(gcProjectFlow);
            	
            	GcProjectQtfy obj = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i]));
        		//发送消息通知
//            	gcSendTipService.sendTip("bzj", obj.getName(), obj.getOrderNo(), 
//            			obj.getCreateUser(), DateUtils.dateTime(obj.getCreateAt()), 
//            			obj.getStatus().toString(), null, obj.getId().toString());
            	
            	try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    		
    	}
    	return toAjax(1);
    }
    
    /**
     * 总经理项目评审
     * @return
     */
    @RequiresPermissions("gcgl:qtfy:zjlpsview")
    @GetMapping("/zjlps")
    public String zjlps(){
        return prefix + "/qtfyzjlps";
    }
    
    /**
     * 查询项目其它费用列表
     */
    @PostMapping("/zjlpslist")
    @ResponseBody
    public TableDataInfo zjlpslist(GcProjectQtfy gcProjectQtfy)
    {
        startPage();
        gcProjectQtfy.setDeleteFlag(1);
        gcProjectQtfy.setStatus(1);
        List<GcProjectQtfy> list = gcProjectQtfyService.selectGcProjectYbfyList(gcProjectQtfy);
        for(GcProjectQtfy obj:list){
        	if(obj.getZlwj()!=null && !obj.getZlwj().equals("")){
        	obj.setZlwj(RuoYiConfig.getOnPath()+obj.getZlwj());
        	}
        }
        return getDataTable(list);
    }
    
    @Log(title = "通过", businessType = BusinessType.UPDATE)
    @PostMapping("/zjlyes")
    @ResponseBody
    public AjaxResult zjlyes(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcProjectQtfy qtfy = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i].toString()));
    		if(qtfy!=null){
    			GcProjectQtfy gcProjectQtfy = new GcProjectQtfy();
        		gcProjectQtfy.setId(Long.parseLong(id[i]));
        		gcProjectQtfy.setStatus(3);
        		gcProjectQtfy.setZjl(getLoginName());
        		gcProjectQtfy.setZjlAt(new Date());
        		gcProjectQtfy.setSpyj(spyj);
        		gcProjectQtfyService.updateGcProjectYbfy(gcProjectQtfy);
            	
            	GcProjectFlow gcProjectFlow = new GcProjectFlow();
            	gcProjectFlow.setGcProjectid(qtfy.getGcProjectid());
            	gcProjectFlow.setXmqtfy(2);
            	gcProjectFlow.setUpdateAt(new Date());
            	gcProjectFlow.setUpdateUser(getLoginName());
            	gcProjectFlowService.updateGcProjectFlow(gcProjectFlow);
            	
            	GcProjectQtfy obj = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i]));
        		//发送消息通知
//            	gcSendTipService.sendTip("bzj", obj.getName(), obj.getOrderNo(), 
//            			obj.getCreateUser(), DateUtils.dateTime(obj.getCreateAt()), 
//            			obj.getStatus().toString(), null, obj.getId().toString());
            	
            	try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    		
    	}
    	
    	return toAjax(1);
    }
    
    @Log(title = "不通过", businessType = BusinessType.UPDATE)
    @PostMapping("/zjlno")
    @ResponseBody
    public AjaxResult zjlno(String ids,String spyj, ModelMap mmap){
    	String[] id = Convert.toStrArray(ids);
    	for(int i=0;i<id.length;i++){
    		GcProjectQtfy qtfy = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i].toString()));
    		if(qtfy!=null){
    			GcProjectQtfy gcProjectQtfy = new GcProjectQtfy();
        		gcProjectQtfy.setId(Long.parseLong(id[i]));
        		gcProjectQtfy.setStatus(4);
        		gcProjectQtfy.setZjl(getLoginName());
        		gcProjectQtfy.setZjlAt(new Date());
        		gcProjectQtfy.setSpyj(spyj);
            	gcProjectQtfyService.updateGcProjectYbfy(gcProjectQtfy);
            	
            	GcProjectFlow gcProjectFlow = new GcProjectFlow();
            	gcProjectFlow.setGcProjectid(qtfy.getGcProjectid());
            	gcProjectFlow.setXmqtfy(0);
            	gcProjectFlow.setUpdateAt(new Date());
            	gcProjectFlow.setUpdateUser(getLoginName());
            	gcProjectFlowService.updateGcProjectFlow(gcProjectFlow);
            	
            	GcProjectQtfy obj = gcProjectQtfyService.selectGcProjectYbfyById(Long.parseLong(id[i]));
        		//发送消息通知
//            	gcSendTipService.sendTip("bzj", obj.getName(), obj.getOrderNo(), 
//            			obj.getCreateUser(), DateUtils.dateTime(obj.getCreateAt()), 
//            			obj.getStatus().toString(), null, obj.getId().toString());
            	
            	try {
            		List<Map> userlis = gcSendTipMapper.selectGcToUserByName(obj.getCreateUser());
            		if(userlis!=null && userlis.size()>0){
            			String phonenumber = userlis.get(0).get("phonenumber").toString();//创建人
            			AliyunSmsUtils.returnSmsTz(phonenumber);
            		}
    			} catch (Exception e) {
    				// TODO: handle exception
    				e.printStackTrace();
    			}
    		}
    		
    	}
    	return toAjax(1);
    }
    
    /**
     * 修改项目其它费用
     */
    @GetMapping("/detailgcsp/{id}")
    public String detailgcsp(@PathVariable("id") Long id, ModelMap mmap){
        GcProjectQtfy gcProjectQtfy = gcProjectQtfyService.selectGcProjectYbfyById(id);
        if(gcProjectQtfy.getZlwj()!=null && !gcProjectQtfy.getZlwj().equals("")){
        	String[] zlis = gcProjectQtfy.getZlwj().split(",");
        	String file = "";
        	for(int i=0;i<zlis.length;i++){
        		file += RuoYiConfig.getOnPath()+zlis[i]+",";
        	}
        	gcProjectQtfy.setZlwj(file);
        }
        mmap.put("gcProjectQtfy", gcProjectQtfy);
        return prefix + "/detailgcsp";
    }
    
    /**
     * 修改项目其它费用
     */
    @GetMapping("/detailzjlsp/{id}")
    public String detailzjlsp(@PathVariable("id") Long id, ModelMap mmap){
        GcProjectQtfy gcProjectQtfy = gcProjectQtfyService.selectGcProjectYbfyById(id);
        if(gcProjectQtfy.getZlwj()!=null && !gcProjectQtfy.getZlwj().equals("")){
        	String[] zlis = gcProjectQtfy.getZlwj().split(",");
        	String file = "";
        	for(int i=0;i<zlis.length;i++){
        		file += RuoYiConfig.getOnPath()+zlis[i]+",";
        	}
        	gcProjectQtfy.setZlwj(file);
        }
        mmap.put("gcProjectQtfy", gcProjectQtfy);
        return prefix + "/detailzjlsp";
    }
    
    /**
     * 通用上传请求（多个）
     */
    @PostMapping("/uploads")
    @ResponseBody
    public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception{
        try
        {
            // 上传文件路径
            String filePath = RuoYiConfig.getUploadPath();
            List<String> urls = new ArrayList<String>();
            List<String> fileNames = new ArrayList<String>();
            List<String> newFileNames = new ArrayList<String>();
            List<String> originalFilenames = new ArrayList<String>();
            for (MultipartFile file : files)
            {
                // 上传并返回新文件名称
                String fileName = FileUploadUtils.upload(filePath, file);
                String url = serverConfig.getUrl() + fileName;
                urls.add(url);
                fileNames.add(fileName);
                newFileNames.add(FileUtils.getName(fileName));
                originalFilenames.add(file.getOriginalFilename());
            }
            AjaxResult ajax = AjaxResult.success();
            ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
            ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
            ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
            ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
            return ajax;
        }
        catch (Exception e)
        {
            return AjaxResult.error(e.getMessage());
        }
    }
}